#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int B, N;
	scanf("%d %d", &B, &N);
	while (B != 0 && N != 0) {
		int A = 1, difference = 0, minA, minDiff = 1000000;
		int preDiff = difference;
		int power = A;
		while (true) {
			power = A;
			for (int i = 0; i < N - 1; i++) {
				power *= A;
			}
			preDiff = difference;
			difference = power > B ? power - B : B - power;
			
			if (power > B && preDiff < difference)
				break;

			if (difference < minDiff) {
				minA = A;
				minDiff = difference;
			}
			++A;
		}

		printf("%d\n", --A);

		scanf("%d %d", &B, &N);
	}
	return 0;
}
